<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 添加设备信息</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                
                <div class="ibox-content">
                    <form action="" class="form-horizontal" method="post" id="myfoms">
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('机柜号')}</lable>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="cabinet_id" placeholder="{:lang('输入')}{:lang('机柜号')}" required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('物联网卡号码')}</lable>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="networking_card" placeholder="{:lang('输入')}{:lang('物联网卡号码')}" required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('机柜型号')}</lable>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="model" placeholder="{:lang('输入')}{:lang('机柜型号')}" required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('可容纳充电宝数')}</lable>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="devicenum" placeholder="{:lang('输入')}{:lang('可容纳充电宝数')}" required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('选择代理商')}</lable>
                            <div class="col-sm-10">
                                <div class="input-group">
                                    <select data-placeholder="{:lang('选择代理商')}..." class="chosen-select  form-control" id='oid' name="oid" style="width:350px;" tabindex="2" required>
                                    <option value="">{:lang('选择代理商')}</option>
                                    {volist name="ret" id="vv"}
                                    <option value="{$vv.id}" hassubinfo="true">{$vv.name}</option>
                                    {/volist}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-label">{:lang('选择商户')}</lable>
                            <div class="col-sm-10" >
                                <div class="input-group" id="seller">
                                    <select  class="form-control" name="sid" style="width:350px;"  id="sid" required>
                                    <option value="">{:lang('选择商户')}</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                                <div class="col-sm-2 col-sm-offset-1">
                                    <button class="btn btn-primary " type="button" id="bton"><i class="fa fa-check"></i>&nbsp;{:lang('提交')}&nbsp;</button>
                                </div>
                            </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="{$Think.config.site.resource_url}js/content.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <!-- Chosen -->
    <script src="{$Think.config.site.resource_url}js/plugins/chosen/chosen.jquery.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
<script type="text/javascript">
$(function(){
    $('.chosen-select').chosen();
    $('#oid').change(function(){
        var oid = $(this).val();
        $.ajax({
                type : 'POST',
                url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Equipment/sellers',
                dataType : 'json',
                data : {oid:oid},
                async : false,
                success : function(result){
                   if(0 == result.code){
                       $('#sid').html( result.msg );
                       
                       
                       // $("#seller>div#sid_chosen>div.chosen-drop>ul.chosen-results").html("1223333" );
                    }
                       
                },
            });
       
    });
 
        $('#bton').click(function(){
            var formdata = $('#myfoms').serialize();
            $.ajax({
                type : 'POST',
                url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Equipment/add',
                dataType : 'json',
                data : formdata,
                async : false,
                success : function(result){
                    if(1 == result.code){
                        layer.msg(result.msg, {icon: 1});
                        parent.location.reload();
                    }else{
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error : function(){
                    layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                }
            })
        });

    });
</script>
</body>
</html>